package com.shop.coupon.controller;

import com.shop.common.core.domain.Result;
import com.shop.coupon.domain.vo.CouponHistoryVo;
import com.shop.coupon.service.CouponHistoryVoService;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.concurrent.Callable;

@RestController
@RequestMapping("/couponHistoryVo")
public class CouponHistoryVoController {

    private final CouponHistoryVoService couponHistoryVoService;


    public CouponHistoryVoController(CouponHistoryVoService couponHistoryVoService) {
        this.couponHistoryVoService = couponHistoryVoService;
    }

    @PostMapping("/couponUserSelect")
    public Result<Callable<List<CouponHistoryVo>>> couponUserSelect(@RequestBody CouponHistoryVo couponHistoryVo){
        return couponHistoryVoService.couponUserSelect(couponHistoryVo);
    }

    @PostMapping("/couponUserSelectUse")
    public Result<CouponHistoryVo> couponUserSelectUse(@RequestBody CouponHistoryVo couponHistoryVo){
        return couponHistoryVoService.couponUserSelectUse(couponHistoryVo);
    }

    @PostMapping("/couponUserSelectExpired")
    public Result<CouponHistoryVo> couponUserSelectExpired(@RequestBody CouponHistoryVo couponHistoryVo){
        return couponHistoryVoService.couponUserSelectExpired(couponHistoryVo);
    }

    @GetMapping("/couponUserDelete")
    public Result<CouponHistoryVo> couponUserDelete(@RequestParam Long memberId){
        return couponHistoryVoService.couponUserDelete(memberId);
    }

    @PostMapping("/BathCouponVOList")
    public Callable<List<CouponHistoryVo>> BathCouponVOList(@RequestBody CouponHistoryVo couponHistoryVo){
        return new Callable<List<CouponHistoryVo>>() {
            @Override
            public List<CouponHistoryVo> call() throws Exception {
                return couponHistoryVoService.couponUser(couponHistoryVo);
            }
        };
    };

}
